package jkCore;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;

import androidx.annotation.NonNull;

import org.cocos2dx.javascript.AppActivity;
import org.cocos2dx.javascript.service.SDKClass;

import jkCore.utils.Utils;

public class JKManager extends SDKClass {
    private static String TAG = "JKManager";
    private static JKManager instance;
    private static Context mContext;
    private static int onQueryPurchasesResponseCnt;
    private AppActivity mActivity;

    @Override
    public void init(Context context) {
        super.init(context);
        Log.d(TAG, String.format("init"));

        instance = this;
        mContext = context;
        mActivity = (AppActivity) mContext;
    }

    @Override
    public void setGLSurfaceView(GLSurfaceView view) {
        super.setGLSurfaceView(view);
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Log.d(TAG, String.format("onActivityResult requestCode = %s resultCode = %s data = %s", requestCode, resultCode, data));
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        Log.d(TAG, String.format("onRequestPermissionsResult requestCode = %s permissions = %s grantResults = %s", requestCode, permissions, grantResults));
    }

    @Override
    public void onNewIntent(Intent intent) {
    }

    @Override
    public void onRestart() {
    }

    @Override
    public void onStop() {
    }

    @Override
    public void onBackPressed() {
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
    }

    @Override
    public void onStart() {
    }

    @Override
    public void onKeyDown(int keyCode, KeyEvent event) {
        Log.d(TAG, String.format("onActivityResult keyCode = %s", keyCode));

        Utils.callCocos2dxJavascript("JKManager && JKManager.onJavaKeyDown && JKManager.onJavaKeyDown(%s)", keyCode);
    }

// ============================================================================================
// =====================================   内部方法   ===========================================
// ============================================================================================

// ============================================================================================
// =====================================   外部方法   ===========================================
// ============================================================================================

// ============================================================================================
// =====================================   静态方法   ===========================================
// ============================================================================================
}